function createOptions($ele, datas) {
    $.each(datas, function (index, data) {
        $ele.append($("<option>").val(data.id).text(data.name));
    });
}


function init($ele) {
    $ele.append("<option></option>");
    $.getJSON("/student-types", function (res) {
        createOptions($ele, res)
        $ele.find("option[value='" + $ele.data("id") + "']").prop('selected', true);
    });
};

init($("#typeId"));

$(".list").on("click", ".list-delete", function () {
    let url = "/students/" + $(this).attr("data-id") ;
    let $form = $("<form>").attr("action", url).attr("method", "post")
        .appendTo($("body"));
    $form.submit();
});
